package cn.stylefeng.guns.modular.business.frequency.transportleveldetail.mapper;

import cn.stylefeng.guns.modular.business.frequency.ordersub.model.param.OrderDTO;
import cn.stylefeng.guns.modular.business.frequency.ordersub.model.result.PkgTransportLevelDetailSimple;
import cn.stylefeng.guns.modular.business.frequency.transport.model.result.PkgTransportOrderDetail;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import cn.stylefeng.guns.modular.business.frequency.transportleveldetail.entity.TransportLevelDetail;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.List;

/**
 * 运单目的地以及费用记录 Mapper 接口
 *
 * @author yujie
 * @date 2023/05/09 17:15
 */
public interface TransportLevelDetailMapper extends BaseMapper<TransportLevelDetail> {

    TransportLevelDetail getLastTransportLevelDetail(@Param("orderId") Long orderId);

    List<PkgTransportLevelDetailSimple> getPkgTransportLevelDetailSimpleListByOrderId(@Param("id") Long id);

    PkgTransportLevelDetailSimple getPkgTransportLevelDetailSimpleByOrderIdAndTransportId(@Param("orderId") Long orderId,
                                                                                          @Param("transportId") Long transportId);

    void updateCostByOrderIdAndType(@Param("cost") BigDecimal cost, @Param("orderId") Long orderId,
                                    @Param("transportId") Long transportId);

    List<PkgTransportOrderDetail> getTransportOrderDetail(@Param("orderDTO") OrderDTO orderDTO, @Param("tenantId") Long tenantId);

    List<Long> getRectangularCustomerOrderIds(@Param("transportId") Long transportId, @Param("orderIds") List<Long> orderIds);

    TransportLevelDetail getByLevelIdAndOrderId(@Param("levelId") Long levelId, @Param("orderId") Long orderId);

    void deleteByLevelId(@Param("levelId") Long id);



    int countUnSignedCount(@Param("transportId") Long transportId, @Param("orderId") Long orderId);

    int countUnDeliveryCount(@Param("transportId") Long transportId, @Param("orderId") Long orderId);


    int countLevelUnSigned(@Param("levelId") Long levelId, @Param("orderId") Long orderId);


    @Select("select order_id from tt_transport_level_detail where level_id = #{levelId}")
    List<Long> getOrderIdListByLevelId(@Param("levelId")Long levelId);


}